package com.itboye.mengwu.app.adapter;

import java.util.List;

import com.itboye.mengwu.R;
import com.itboye.mengwu.app.MainApplication;
import com.itboye.mengwu.data.model.TieZiBaoHanReply.GetAList.ReplyInfo.ReContent;
import com.itboye.mengwu.luntan.comment.adapter.CommentReplyAdapter.ViewHolder;

import android.content.Context;
import android.graphics.Color;
import android.text.Html;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class YuErJingCommentAdapter extends BaseAdapter {
	private LayoutInflater inflater;
	private int parentPosition = -1;
	private List<ReContent> replyList;

	public YuErJingCommentAdapter(Context context, List<ReContent> replyList,
			int parentPosition) {
		this.inflater = LayoutInflater.from(context);
		this.parentPosition = parentPosition;
		this.replyList = replyList;
	}

	@Override
	public int getCount() {
		int count = replyList.size();
		return replyList.size();
	}

	public void clearList() {
		this.replyList.clear();
	}

	public void updateList(List<ReContent> replyList) {
		this.replyList.addAll(replyList);
	}

	@Override
	public ReContent getItem(int position) {
		return replyList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder viewHolder = null;
		convertView = inflater.inflate(R.layout.item_comment_reply_small,
				null);
		viewHolder = new ViewHolder();
		viewHolder.tv_comment_reply_text = (TextView) convertView
				.findViewById(R.id.tv_msg_content);  
		
		viewHolder.huifupinglun = (LinearLayout) convertView
				.findViewById(R.id.huifupinglun);
		viewHolder.more = (TextView) convertView.findViewById(R.id.more);
		viewHolder.re=(RelativeLayout) convertView.findViewById(R.id.re);
		convertView.setTag(viewHolder);
		ReContent reply = getItem(position);
		// if (!reply.getId().equals("0")) {// �ظ�����
		// viewHolder.huifu.setVisibility(View.VISIBLE);
		// viewHolder.tv_comment_reply_writer.setText(reply.getAuthor());
		// viewHolder.tv_comment_reply_writer2.setVisibility(View.VISIBLE);
		// viewHolder.tv_comment_reply_writer2.setText(reply.getToUinfo().getNickname());
		// }

		// if(reply.getComments()!=null){// ����
		// for (int i = 0; i < reply.getComments().size(); i++) {
		// View viewHuiFu = LayoutInflater.from(
		// MainApplication.context).inflate(
		// R.layout.huifupinglun, null);
		// TextView huifupinglun_content = (TextView) viewHuiFu
		// .findViewById(R.id.huifupinglun_content);
		// TextView huifupinglun_writer = (TextView) viewHuiFu
		// .findViewById(R.id.huifupinglun_writer);
		// huifupinglun_content.setText(reply.getComments().get(i)
		// .getComment());
		// huifupinglun_writer.setText(reply.getComments().get(i)
		// .getAuthor()
		// + " :");
		// viewHuiFu.setTag(reply.getComments().get(i).getAuthorId());
		// viewHuiFu.setTag(R.id.tag_first,position);
		// viewHuiFu.setTag(R.id.tag_second,i);
		// viewHolder.huifupinglun.addView(viewHuiFu);
		// }
		// // viewHolder.huifu.setVisibility(View.GONE);
		// // viewHolder.huifupinglun_content.setVisibility(View.GONE);
		// // viewHolder.huifupinglun_writer.setText(reply.getAuthor() +
		// // ":");
		// if(reply.getComments().size()>=3){
		// viewHolder.more.setVisibility(View.VISIBLE);
		// // viewHolder.more.setOnClickListener(viewMoreOnclickListener);
		// viewHolder.more.setTag(position);
		// }else{
		// viewHolder.more.setVisibility(View.GONE);
		// }
		// }
		// viewHolder.tv_comment_reply_text.setText(reply.getComment());

		
		viewHolder.tv_comment_reply_text.setText(Html.fromHtml("<font color=#ff6ea5>"
				+ reply.getAuthor()+
				"</font >:"
				
				));
		
		viewHolder.tv_comment_reply_text.append(reply.getMessage());

		// �ж��ǻظ�¥�����߻ظ�������
		// if (TextUtils.isEmpty(reply.get)) {

		// } else {
	
		
		// }
		// ��¼����ظ�ʱ����Ӧ��position,����ȷ�����ظ��Ķ��������¥��¥�������¼���ڵ��position
		// convertView.setTag(R.id.tag_first, parentPosition);
		// convertView.setTag(R.id.tag_second, position);
		return convertView;
	}

	public class ViewHolder {
	 // �������ǳ�
		private TextView tv_comment_reply_text,more; // ���� ����
		LinearLayout huifupinglun;
		RelativeLayout re;
	}
}
